package com.jfs.zlk.init;

import com.jfs.zlk.config.ZlkMediaServerInfo;
import com.jfs.zlk.service.ZlkMediaServerService;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.SmartFactoryBean;
import org.springframework.stereotype.Component;

/**
 * @Description 初始化服务器配置信息
 * SmartFactoryBean isEagerInit() true spring容器初始化单列bean时候会初始化getObject()返回的bean对象
 * @E-mail cwm3412638@163.com
 * @Author cwm
 * @Date 2022/7/27
 */
@Component
@AllArgsConstructor
public class ZlkMediaServerInfoFactoryBean implements SmartFactoryBean<ZlkMediaServerInfo> {
    private final ZlkMediaServerService zlkMediaServerService;

    @Override
    public boolean isEagerInit() {
        return true;
    }

    @Override
    public ZlkMediaServerInfo getObject() throws Exception {
        return zlkMediaServerService.getServerConfig();
    }

    @Override
    public Class<?> getObjectType() {
        return ZlkMediaServerInfo.class;
    }
}
